<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>添加运维账号 - Layui</title>
<link rel="stylesheet" href="/layui/css/layui.css">
<link rel="stylesheet" href="/css/admin.css">
</head>
<body style="background-color:#F1F1F1">
 
  <div class="layui-body" style="padding-top: 120px;">
    <div class="layui-form-item">
      <label class="layui-form-label">运维账号</label>
      <div class="layui-input-inline">
        <input type="text" name="username" lay-verify="pass" value="" autocomplete="off" class="layui-input username">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">密码</label>
      <div class="layui-input-inline">
        <input type="text" name="password" lay-verify="pass" value="" autocomplete="off" class="layui-input password">
      </div>
    </div>
    <button class="layui-btn" lay-submit="" lay-filter="" style="margin-left:110px">添加</button>    

  </div>
</body>
</html>

<script src="/layui/layui.js"></script>
<script src="/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
layui.use('layer', function(){
$(function(){
  var index = parent.layer.getFrameIndex(window.name);
  $('.layui-btn').click(function(){
  var username = $('.username').val();
  var password = $('.password').val();
  if(username==""||password==""){
    layer.msg('用户名和密码必填!');
  }else{
    $.ajax({
      url:"/admin/admin/doaddoper",
      type:'post',
      data:{'username':username,'password':password},
      dataType:'json',
      success:function(d){
        if(d.code==20){           
         // window.location.reload();
          layer.msg(d.msg,{
              icon: 1,
              time: 1000 //2秒关闭（如果不配置，默认是3秒）
              }, function(){
                parent.layer.close(index);
                window.loaction.reload();
        });
        }else{
          layer.msg(d.msg);
        }
      }
    })
   }
  })
 })
})

layui.use('element', function(){

  var element = layui.element(); //导航的hover效果、二级菜单等功能，需要依赖element模块
});

</script>

